package com.nine.design.pay.v2;

import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Slf4j
public class HandlerStrategyFactory {

    private static Map<String, HandlerStrategy> map = new ConcurrentHashMap<>();

    public static HandlerStrategy getStrategy(String type) {
        return map.get(type);
    }

    // 注册支付方式
    public static void register(String type, HandlerStrategy strategy) {
        log.info("将支付方式，注册进系统中，type：{}，strategy：{}", type, strategy);
        map.put(type, strategy);
    }

}
